#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') f=1;
		ch=getchar();
	}
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
inline void write(int x){
	if(x==0){putchar('0');return;}
	char ch[10];int cnt=-1;
	while(x){
		ch[++cnt]=(x%10)^48;
		x/=10;
	}
	for(int i=cnt;~i;--i) putchar(ch[i]);
}
inline int sqr(int x){return x*x;}
inline int ceildiv(int x,int y){return (x-1)/y+1;}
struct Car{
	int s,v,a;
	Car(){}
	Car(int x,int y,int z){s=x;v=y;a=z;}
};
int T,n,m,L,V;
Car a[100005];
int p[100005];
int lb[1000005];
int tot;
pair<int,int> b[100005];
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	T=read();
	while(T--){
		n=read();m=read();L=read();V=read();
		for(int i=1;i<=n;++i){
			a[i].s=read();
			a[i].v=read();
			a[i].a=read();
		}
		for(int i=0;i<=L+1;++i) lb[i]=-1;
		for(int i=1;i<=m;++i) p[i]=read(),lb[p[i]]=i;
		for(int i=L+1,lst=-1;~i;--i){
			if(lb[i]!=-1) lst=lb[i];
			else lb[i]=lst;
		}
		for(int i=0;i<=L+1;++i)
			if(lb[i]==-1) lb[i]=m+1;
		tot=0;
		for(int i=1;i<=n;++i){
			if(a[i].v<=V&&a[i].a<=0) continue;
			if(a[i].v>V&&a[i].a>=0){
				if(lb[a[i].s]<=m) b[++tot]=make_pair(lb[a[i].s],m);
			}else if(a[i].v<=V){
				int pos=ceildiv(sqr(V)-sqr(a[i].v)+1,a[i].a*2)+a[i].s;
				if(pos>L||lb[pos]>m) continue;
				b[++tot]=make_pair(lb[pos],m);
			}else{
				int pos=(sqr(a[i].v)-sqr(V)-1)/((-a[i].a)*2)+a[i].s;
				pos=min(pos,L);
				if(lb[a[i].s]>=lb[pos+1]) continue;
				b[++tot]=make_pair(lb[a[i].s],lb[pos+1]-1);
			}
		}
		sort(b+1,b+tot+1,[&](pair<int,int> x,pair<int,int> y){return x.second<y.second;});
		int ans=0;
		for(int i=1,j=0;i<=tot;++i)
			if(b[i].first>j){
				j=b[i].second;
				++ans;
			}
		write(tot);putchar(' ');write(m-ans);putchar('\n');
	}
	return 0;
}